package jvs.vfs;

import java.util.Comparator;

import x.java.io.File;

public class FileComparator implements Comparator<Object> {

	public int compare(Object o1, Object o2) {
		return compare((File)o1,(File)o2);
	}

	public static int compare(File f1, File f2) {
		if (f1 == f2) {
			return 0;
		}
		boolean isdir1 = f1.isDirectory();
		boolean isdir2 = f2.isDirectory();
		if (isdir1 && !isdir2) {
			return -1;
		}
		if (!isdir1 && isdir2) {
			return 1;
		}
		return f1.getPath().compareTo(f2.getPath());
	}
}
